const { Article } = require('../model/article')
const { User } = require('../model/user');
const { Like } = require('../model/like')
/**
 * 获取用户总数
 */
exports.getUserCount = async (req, res, next) => {
    try {
        const userCount = await User.count()
        res.status(200).json({
            userCount
        })
    } catch (err) {
        next(err)
    }
}

/**
 * 获取文章总数
 */
exports.getArticleCount = async (req, res, next) => {
    try {
        const articleCount = await Article.count()
        res.status(200).json({
            articleCount
        })
    } catch (err) {
        next(err)
    }
}

/**
 * 获取浏览总数
 */
exports.getWatchCount = async (req, res, next) => {
    try {
        const watchCount = await Article.sum('watchSum')
        res.status(200).json({
            watchCount
        })
    } catch (err) {
        next(err)
    }
}

/**
 * 获取点赞总数
 */
exports.getLikeCount = async (req, res, next) => {
    try {
        const likeCount = await Like.count()
        res.status(200).json({
            likeCount
        })
    } catch (err) {
        next(err)
    }
}